Refactor DateTimeRangePicker again#1247
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
3e55163 to
09681e6
Compare
3679f13 to
acb6951
Compare
david-crespo
commented
Nov 9, 2022
|
|
||
| return () => vi.useRealTimers() | ||
| }) | ||
|
|
Collaborator
Author
There was a problem hiding this comment.
this wasn't working before, now it is? ok
david-crespo
commented
Nov 9, 2022
| setStartTime(newStart) | ||
| setEndTime(newEnd) | ||
| } | ||
| }, []) |
Collaborator
Author
There was a problem hiding this comment.
Certainly no reason not to memoize here. And I need it in the picker because a useCallback depends on this.
DateTimeRangePicker
DateTimeRangePickerDateTimeRangePicker again
david-crespo
commented
Nov 9, 2022
| const intervalId = setInterval(() => callbackRef.current?.(), delay) | ||
| return () => clearInterval(intervalId) | ||
| }, [delay]) | ||
| }, [delay, key]) |
Collaborator
Author
There was a problem hiding this comment.
Without key, this will only clear (and possibly remake) the interval if the delay changes. But if you want to delete and remake the interval while keeping the delay the same, you change key.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In #1225 I split the picker into a component and a hook, and callers have to use both. As I tried to work on the refetch interval picker, I got madder and madder about that setup, so this is me cleaning that up. The real problem I had that caused the original refactor was that the tests weren't working as I expected. Because the component is split out nicely, the tests can exercise the component but I can still use the hook that wraps the component for the actual code.
Despite the branch name, this does not add any refetch controls. One real change that's made here is the behavior is more correct when switching range presets. As you would expect, the old refetch interval is cleared when the new one is created.